package com.by.order.api.service;

import java.io.Serializable;
import java.util.List;

/**
 * 事务监控和管理服务接口
 * 提供事务状态的监控和统计，以及人工干预功能
 */
public interface ITransactionManagementService {
    
    /**
     * 获取所有消息的统计信息
     * @return 消息统计信息
     */
    MessageStatistics getMessageStatistics();
    
    /**
     * 重新发送失败的消息
     * @param messageId 消息ID
     * @return 是否操作成功
     */
    boolean resendFailedMessage(String messageId);
    
    /**
     * 手动标记消息为已发送
     * @param messageId 消息ID
     * @return 是否操作成功
     */
    boolean markAsSent(String messageId);
    
    /**
     * 获取指定状态的消息列表
     * @param status 消息状态
     * @param limit 返回记录数限制
     * @return 消息列表
     */
    List<MessageInfo> getMessagesByStatus(Integer status, int limit);
    
    /**
     * 消息统计信息类
     */
    class MessageStatistics implements Serializable {
        private static final long serialVersionUID = 1L;
        
        private long pendingCount;    // 待确认消息数
        private long toSendCount;     // 待发送消息数
        private long sentCount;       // 已发送消息数
        private long failedCount;     // 发送失败消息数
        
        // Getters and Setters
        public long getPendingCount() {
            return pendingCount;
        }
        
        public void setPendingCount(long pendingCount) {
            this.pendingCount = pendingCount;
        }
        
        public long getToSendCount() {
            return toSendCount;
        }
        
        public void setToSendCount(long toSendCount) {
            this.toSendCount = toSendCount;
        }
        
        public long getSentCount() {
            return sentCount;
        }
        
        public void setSentCount(long sentCount) {
            this.sentCount = sentCount;
        }
        
        public long getFailedCount() {
            return failedCount;
        }
        
        public void setFailedCount(long failedCount) {
            this.failedCount = failedCount;
        }
        
        @Override
        public String toString() {
            return "MessageStatistics{" +
                    "pendingCount=" + pendingCount +
                    ", toSendCount=" + toSendCount +
                    ", sentCount=" + sentCount +
                    ", failedCount=" + failedCount +
                    '}';
        }
    }
    
    /**
     * 消息信息类
     */
    class MessageInfo implements Serializable {
        private static final long serialVersionUID = 1L;
        
        private Long id;
        private String messageId;
        private String messageBody;
        private Integer status;
        private String businessId;
        private Integer tryCount;
        private java.time.LocalDateTime nextTryTime;
        private java.time.LocalDateTime createTime;
        private java.time.LocalDateTime updateTime;
        
        // Getters and Setters
        public Long getId() {
            return id;
        }
        
        public void setId(Long id) {
            this.id = id;
        }
        
        public String getMessageId() {
            return messageId;
        }
        
        public void setMessageId(String messageId) {
            this.messageId = messageId;
        }
        
        public String getMessageBody() {
            return messageBody;
        }
        
        public void setMessageBody(String messageBody) {
            this.messageBody = messageBody;
        }
        
        public Integer getStatus() {
            return status;
        }
        
        public void setStatus(Integer status) {
            this.status = status;
        }
        
        public String getBusinessId() {
            return businessId;
        }
        
        public void setBusinessId(String businessId) {
            this.businessId = businessId;
        }
        
        public Integer getTryCount() {
            return tryCount;
        }
        
        public void setTryCount(Integer tryCount) {
            this.tryCount = tryCount;
        }
        
        public java.time.LocalDateTime getNextTryTime() {
            return nextTryTime;
        }
        
        public void setNextTryTime(java.time.LocalDateTime nextTryTime) {
            this.nextTryTime = nextTryTime;
        }
        
        public java.time.LocalDateTime getCreateTime() {
            return createTime;
        }
        
        public void setCreateTime(java.time.LocalDateTime createTime) {
            this.createTime = createTime;
        }
        
        public java.time.LocalDateTime getUpdateTime() {
            return updateTime;
        }
        
        public void setUpdateTime(java.time.LocalDateTime updateTime) {
            this.updateTime = updateTime;
        }
    }
}